# 119. 杨辉三角 II

var getRow = function(rowIndex) {
  const resArr = []

  for (let i = 0; i <= rowIndex; i++) {
    const res = Array(i + 1).fill(1)
    for (let j = 1; j < res.length - 1; j++) {
      res[j] = resArr[i - 1][j - 1] + resArr[i - 1][j]
    }
    resArr.push(res)
  }

  return resArr[rowIndex]
}
console.log(getRow(3))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Last Updated: 6/27/2023, 7:40:45 PM